package ${package};

import lombok.Data;
import java.util.*;
<#list model.fields as field>
import ${field.typePackage}.*;
</#list>

@Data
public class ${model.identifier?cap_first} {
    <#list model.fields as field>
    private ${field.javaType} ${field.name};
    </#list>

    public ${model.identifier?cap_first}() {
        <#list model.fields as field>
        <#if field.defaultValue??>
        this.${field.name} = ${field.defaultValue};
        </#if>
        </#list>
    }

    public ValidationResult validate() {
        ValidationResult result = new ValidationResult();
        <#list model.validationRules as rule>
        if (!${rule.expression}) {
            result.addError("${rule.field}", "${rule.errorMessage}");
        }
        </#list>
        return result;
    }
}